package com.example.mapper;


import com.example.bean.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookMapper{

    @Select("SELECT * FROM book WHERE bookId=#{id}")
    public Book selectBookById(String id);   //根据图书Id查找图书
    @Select("SELECT * FROM book WHERE bookName=#{bookName}")
    public List<Book> selectBookByName(String bookName);  //根据图书名字查找图书
    @Select("SELECT * FROM book")
    public List<Book> selectBook();             //多条件查询
    @Insert("INSERT INTO book(bookId,bookName,author,publish,publishDate,introduction,type,language,price,status) VALUES(#{bookId},#{bookName},#{author},#{publish},#{publishDate},#{introduction},#{type},#{language},#{price},#{status})")
    public int insertBook(Book book);     //添加图书
    @Delete("DELETE FROM book WHERE bookId=#{bookId}")
    public int deleteBook(String id);    //删除图书
    @Update("UPDATE book SET bookName=#{bookName},author=#{author},publish=#{publish},publishDate=#{publishDate},introduction=#{introduction},type=#{type},language=#{language},price=#{price},status=#{status} WHERE bookId=#{bookId}")
    public int updateBook(Book book);  //更新图书
}
